//
//  PlayerTableViewCell.m
//  EDPS
//
//  Created by 张维扬 on 15/12/3.
//  Copyright © 2015年 张维扬. All rights reserved.
//

#import "PlayerTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "Masonry.h"
@interface PlayerTableViewCell ()
@property (nonatomic, retain) UIImageView *img;
@property (nonatomic, strong) UILabel *title;

@end

@implementation PlayerTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.img = [[UIImageView alloc] init];
        [self.contentView addSubview:self.img];
        
        self.title = [[UILabel alloc] init];
        [self.title setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
        self.title.textColor = [UIColor whiteColor];
        self.title.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.title];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(self.contentView);

    }];
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, 50));
    }];
}
- (void)setModel:(PlayerModel *)model
{
    if (_model != model) {
        _model = model;
    }
    [self.img sd_setImageWithURL:[NSURL URLWithString:model.coverForFeed] placeholderImage:[UIImage imageNamed:@"hold"]];
    self.title.text = model.title;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
